package org.lee.validate.custom;

import org.lee.validate.custom.annotation.Age;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * AgeValidate
 *
 * @author dralee
 * @date 2021-12-24 15:16:20
 **/
public class AgeValidator implements ConstraintValidator<Age, Object> {

    @Override
    public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
        int age = (int) o;
        return age > 0 && age <= 120;
    }
}
